// 小票所有字体
var sizeOne = 13;
var sizeTwo = 12;
var sizeThree = 10;
var sizeFour = 8;

function testPrintNew(){

	LODOP.PRINT_INIT("连锁店单据过账——小票打印");
	LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
	LODOP.ADD_PRINT_TEXT(10, 0, 580, 10, "---千禧宝贝小票打印测试-----");
	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);

	LODOP.SET_PRINT_PAGESIZE(1, 580, 100, "");
	LODOP.PRINT();
	

}


// 回调函数	 (** 新建零售单 -- 单据过账)
function backProcessGetChainSalesOrderTwo(data) {
	
	// 获取打印份数
	var printCopy = data.response.returnValue.chainStoreConf.printCopy;

	for (i = 0; i < printCopy; i++) {
		printReceipts(data);
	}

}

function printReceipts(data) {


	// 连锁店地址
	var chainAddress = data.response.returnValue.chainStoreConf.address;
	var addressOne = null;
	var addressTwo = null;
	if(chainAddress.length>17){
		addressOne = chainAddress.substring(0,17);
		addressTwo = chainAddress.substring(17,chainAddress.length);
	}else {
		addressOne = chainAddress;
	}

	// 是否隐藏折扣
	var hideDiscountPrint = data.response.returnValue.chainStoreConf.hideDiscountPrint;

	//获取销售商品,退货商品,赠送商品
	var response = data.response;
	var returnCode = response.returnCode;
	//销售商品
	var sale = response.returnValue.productList;
	// 退货商品
	var refund = response.returnValue.productListR;
	// 赠送商品
	var give = response.returnValue.productListF;

	var refundMonty = response.returnValue.netAmountR;
	//预存金消费
	var consumption = response.returnValue.chainPrepaidAmt;
	// 获取连锁店名称
	var chainName = response.returnValue.chainStore.chain_name;
	// 获取单据号
	var documentNumber = response.returnValue.id;
	// 收银员
	var chainUser = response.returnValue.saler.user_name;
	//优惠
	var preferential = response.returnValue.discountAmount;
	//代金卷
	var voucher = response.returnValue.coupon;
	//积分换现金
	var integral = response.returnValue.vipScore;
	//应收
	var receivable = response.returnValue.netAmount - refundMonty
			- preferential - voucher - consumption - integral;
	//刷卡
	var swipe = response.returnValue.cardAmount;
	//现金
	var cash = response.returnValue.cashAmount;
	//微信
	var weChat = response.returnValue.wechatAmount;
	//支付宝
	var alipay = response.returnValue.alipayAmount;
	//找零
	var change = swipe + cash + weChat + alipay - receivable;
	// 获取vip信息
	var vipCard = response.returnValue.vipCard.customerName;
	var totalScore = $("#totalScoreTwo").val();
	var totalVipPrepaid = $("#totalVipPrepaidTwo").val();
	// 时间
	var time = getFormattedTime();
	console.log(time);

	LODOP.PRINT_INIT("连锁店单据过账——小票打印");
	LODOP.SET_PRINT_STYLE("FontSize", sizeOne);
	LODOP.ADD_PRINT_TEXT(5, 0, 580, 10, "千禧宝贝童装连锁");
	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
	LODOP.SET_PRINT_STYLE("FontSize", sizeTwo);
	LODOP.ADD_PRINT_TEXT(25, 0, 580, sizeThree, chainName);
	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
	LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
	LODOP.ADD_PRINT_LINE(50, 5, 50, 150, 1, 1);
	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
	var height = 60;
	// 销售商品
	if (sale.length > 0) {
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "售出货品:");
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		height = height + 20;
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "商品    数量    单价/折扣   总价");
		for (var i = 1; i <= sale.length; i++) {
			LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
			var t = sale[i - 1].productBarcode.product.productCode; // 货号
			var y = sale[i - 1].productBarcode.product.brand.brand_Name; // 品牌
			height = height + 20;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, t + "-" + y);
			var sum = sale[i - 1].quantity;// 数量
			//var q = sale[i - 1].retailPrice;//总价
			var q = sale[i - 1].quantity*sale[i - 1].retailPrice * sale[i - 1].discountRate;//总价
			var w = sale[i - 1].discountRate;//折扣
			var r = sale[i - 1].retailPrice; // 单价
			height = height + 20;
			if (hideDiscountPrint == 1) {
				LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, sum.toFixed(0) + " "
						 + " " + q.toFixed(1));
			} else {
				LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, sum.toFixed(0) + " "
						+ r.toFixed(0) + "/" + w.toFixed(2) + " " + q.toFixed(0));
			}

		}
	}
	// 退换货品
	if (refund.length > 0) {
		height += 20;
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "退换货品:");
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "商品    数量    单价/折扣   总价");
		for (var i = 1; i <= refund.length; i++) {
			LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
			var t = refund[i - 1].productBarcode.product.productCode; // 货号
			var y = refund[i - 1].productBarcode.product.brand.brand_Name; // 品牌
			height = height + 20;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, t + "-" + y);
			var sum = refund[i - 1].quantity;// 数量
			var q = refund[i - 1].quantity*refund[i - 1].retailPrice * refund[i - 1].discountRate;//总价
			var w = refund[i - 1].discountRate;//折扣
			var r = refund[i - 1].retailPrice; // 单价
			height = height + 20;
			if (hideDiscountPrint == 1) {
				LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, sum.toFixed(0) + " "
						+ " " + q.toFixed(0));
			} else {
				LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, sum.toFixed(0) + " "
						+ r.toFixed(0) + "/" + w.toFixed(2) + " " + q.toFixed(0));
			}
		}
	}

	// 赠送货品
	if (give.length > 0) {
		height += 20;
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "赠送货品:");
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "商品    数量    单价/折扣   总价");
		for (var i = 1; i <= give.length; i++) {
			LODOP.SET_PRINT_STYLE("FontSize", 10);
			var t = give[i - 1].productBarcode.product.productCode; // 货号
			var y = give[i - 1].productBarcode.product.brand.brand_Name; // 品牌
			
			var sum = give[i - 1].quantity;// 数量
			var q = give[i - 1].quantity*give[i - 1].retailPrice * give[i - 1].discountRate;//总价
			var w = give[i - 1].discountRate;//折扣
			var r = give[i - 1].retailPrice; // 单价

			height = height + 20;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 20,t + "-" + y+"   "+ sum.toFixed(0));

		}
	}

	height += 20;
	LODOP.ADD_PRINT_LINE(height, 5, height, 100, 1, 1);
	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
	LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "优惠:" + preferential.toFixed(1)
			+ ",代金卷:" + voucher.toFixed(1));
	LODOP.SET_PRINT_STYLE("FontSize", 10);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "应收:" + receivable.toFixed(1)
			+ ",积分换现金:" + integral.toFixed(1));
	LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "刷卡：" + swipe.toFixed(1) + ", 现金:"
			+ cash.toFixed(1));
	LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "微信：" + weChat.toFixed(1)
			+ ", 支付宝：" + alipay.toFixed(1));
	LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "预存金消费:" + consumption.toFixed(1)
			+ ", 找零：" + change.toFixed(1));
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);

	if (vipCard != null) {

		height += 30;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "vip:" + vipCard);
		LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "当前积分:" + totalScore);
		LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "剩余预存金:" + totalVipPrepaid);
		LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	}

	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "此小票是七日换货凭证,请妥善保存");
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "(洗涤,人为原因,特价商品概不调换,");
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "特价商品不在三包范围之内");
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "服务热线：400—606—0849");
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "微信号：QXbaby-HK");
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 30;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "单据号:" + documentNumber);
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "收银员:" + chainUser);
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "欢迎下次光临：" + time);
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "地址：" + addressOne);
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	if(addressTwo != null){
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 60,addressTwo);  // 地址长度超过17, 开启第二行
		LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	}

	
	LODOP.SET_PRINT_PAGESIZE(1, 580, height * 3 - 40, "");
	//打印预览方法
	//LODOP.PREVIEW();   
	LODOP.PRINT();
}

// 回调函数	(** 搜索零售单据 )
function backProcessGetChainSalesOrderThree(data) {
	
	var response = data.response;
	var returnValue = response.returnValue;

	// 获取连锁店名称
	var chainName = returnValue.chainStore.chain_name;
	// 收银员
	var chainUser = returnValue.creator.user_name;
	//优惠
	var preferential = returnValue.discountAmount;
	//代金卷
	var voucher = returnValue.coupon;
	//应收
	var receivable = returnValue.netAmount -  returnValue.discountAmount - returnValue.coupon -returnValue.netAmountR - returnValue.chainPrepaidAmt - returnValue.vipScore;
	//积分换现金
	var integral = returnValue.vipScore;
	//刷卡
	var swipe = returnValue.cardAmount;
	//现金
	var cash = returnValue.cashAmount;
	//微信
	var weChat = returnValue.wechatAmount;
	//支付宝
	var alipay = returnValue.alipayAmount;
	//预存金消费
	var consumption = returnValue.chainPrepaidAmt;
	//找零
	var change = returnValue.returnAmount;
	//重打小票过账时间
	var orderCreateDate = returnValue.orderCreateDate;
	
	var vipName = data.response.returnValue.vipCard.customerName;
	
	// 是否隐藏折扣
	var hideDiscountPrint = data.response.returnValue.chainStoreConf.hideDiscountPrint;

	//获取销售商品,退货商品,赠送商品
	var response = data.response;
	var returnCode = response.returnCode;
	// 单据号
	var documentNumber  = response.returnValue.id;

	//销售商品
	var sale = response.returnValue.productList;
	// 退货商品
	var refund = response.returnValue.productListR;
	// 赠送商品
	var give = response.returnValue.productListF;

	var time = getFormattedTime();
	console.log(time);

	LODOP.PRINT_INIT("重打小票");
	LODOP.SET_PRINT_STYLE("FontSize", sizeOne);
	LODOP.ADD_PRINT_TEXT(5, 0, 580, 10, "千禧宝贝童装连锁");
	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
	LODOP.SET_PRINT_STYLE("FontSize", sizeTwo);
	LODOP.ADD_PRINT_TEXT(25, 0, 580, sizeThree, chainName);
	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
	LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
	LODOP.ADD_PRINT_LINE(50, 5, 50, 150, 1, 1);
	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);

	var height = 60;

	// 销售商品
	if (sale.length > 0) {
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "售出货品:");
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		height = height + 20;
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "商品    数量    单价/折扣   总价");
		for (var i = 1; i <= sale.length; i++) {
			LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
			var t = sale[i - 1].productBarcode.product.productCode; // 货号
			var y = sale[i - 1].productBarcode.product.brand.brand_Name; // 品牌
			height = height + 20;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, t + "-" + y);
			var sum = sale[i - 1].quantity;// 数量
			var q = sale[i - 1].quantity*sale[i - 1].retailPrice * sale[i - 1].discountRate;//总价
			var w = sale[i - 1].discountRate;//折扣
			var r = sale[i - 1].retailPrice; // 单价
			height = height + 20;
			if (hideDiscountPrint == 1) {
				LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, sum.toFixed(0) + " "
						 + " " + q.toFixed(1));
			} else {
				LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, sum.toFixed(0) + " "
						+ r.toFixed(0) + "/" + w.toFixed(2) + " " + q.toFixed(0));
			}
		}
	}

	// 退换货品
	if (refund.length > 0) {
		height += 20;
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "退换货品:");
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "商品    数量    单价/折扣   总价");
		for (var i = 1; i <= refund.length; i++) {
			LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
			var t = refund[i - 1].productBarcode.product.productCode; // 货号
			var y = refund[i - 1].productBarcode.product.brand.brand_Name; // 品牌
			height = height + 20;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, t + "-" + y);
			var sum = refund[i - 1].quantity;// 数量
			var q = refund[i - 1].quantity*refund[i - 1].retailPrice * refund[i - 1].discountRate;//总价
			var w = refund[i - 1].discountRate;//折扣
			var r = refund[i - 1].retailPrice; // 单价
			height = height + 20;
			if (hideDiscountPrint == 1) {
				LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, sum.toFixed(0) + " "
						 + " " + q.toFixed(1));
			} else {
				LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, sum.toFixed(0) + " "
						+ r.toFixed(0) + "/" + w.toFixed(2) + " " + q.toFixed(0));
			}
		}
	}

	// 赠送货品
	if (give.length > 0) {
		height += 20;
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "赠送货品:");
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "商品    数量    单价/折扣   总价");
		for (var i = 1; i <= give.length; i++) {
			LODOP.SET_PRINT_STYLE("FontSize", 10);
			var t = give[i - 1].productBarcode.product.productCode; // 货号
			var y = give[i - 1].productBarcode.product.brand.brand_Name; // 品牌
			
			var sum = give[i - 1].quantity;// 数量
			var q = give[i - 1].quantity*give[i - 1].retailPrice * give[i - 1].discountRate;//总价
			var w = give[i - 1].discountRate;//折扣
			var r = give[i - 1].retailPrice; // 单价
			height = height + 20;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 20,t + "-" + y+"   "+ sum.toFixed(0));
		}
	}

	height += 20;
	LODOP.ADD_PRINT_LINE(height, 5, height, 100, 1, 1);
	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
	LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "优惠:" + preferential + ",代金卷:"
			+ voucher);
	LODOP.SET_PRINT_STYLE("FontSize", 10);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "应收:" + receivable + ",积分换现金:"
			+ integral);
	LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "刷卡：" + swipe + ", 现金:" + cash);
	LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
	height += 20;
	LODOP
			.ADD_PRINT_TEXT(height, 5, 580, 20, "微信：" + weChat + ", 支付宝："
					+ alipay);
	LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "预存金消费:" + consumption + ", 找零："
			+ change);
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 30;
	if(vipName != null){
		
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "VIP:"+vipName);
		LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
		height += 20;
	}
	
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "此小票是七日换货凭证,请妥善保存");
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "(洗涤,人为原因,特价商品概不调换,");
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "特价商品不在三包范围之内");
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "服务热线：400—606—0849");
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "微信号：QXbaby-HK");
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 30;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "单据号:" + documentNumber);
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "收银员:" + chainUser);
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "欢迎下次光临：" + orderCreateDate);
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "重复打印时间：" + time);
	LODOP.SET_PRINT_STYLE("FontSize", sizeFour);

	LODOP.SET_PRINT_PAGESIZE(1, 580, height * 3 - 40, "");

	//LODOP.PREVIEW();

	LODOP.PRINT();

}

//  vip 充值
function vipRecharge(data) {

	var response = data.response;
	if (response.returnCode == SUCCESS) {
		var prepaid = response.returnValue;
		try {

			//获取销售商品,退货商品,赠送商品
			var response = data.response;
			var returnCode = response.returnCode;

			//预存金消费
			var consumption = response.returnValue.chainPrepaidAmt;
			// 获取连锁店名称
			var chainName = response.returnValue.chainStore.chain_name;
			// 收银员
			var chainUser = response.returnValue.operator.name;
			// 支付类型
			var depositType = response.returnValue.depositType;

			var deposit = "";
			if (depositType == "C") {
				deposit = "现金";
			} else if (depositType == "D") {
				deposit = "刷卡";
			} else if (depositType == "W") {
				deposit = "微信";
			} else if (depositType == "A") {
				deposit = "支付宝";
			} else {
				deposit = "";
			}

			//充值金额
			var money = response.returnValue.amount;
			// 剩余金额
			var accumulateVipPrepaid = response.returnValue.accumulateVipPrepaid;
			// 实际金额
			var calculatedAmt = response.returnValue.calculatedAmt;
			// 备注
			var comment = response.returnValue.comment;

			var time = getFormattedTime();

			LODOP.PRINT_INIT("连锁店单据过账——小票打印");
			LODOP.SET_PRINT_STYLE("FontSize", sizeOne);
			LODOP.ADD_PRINT_TEXT(5, 0, 580, 10, "千禧宝贝童装连锁-预存金");
			LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
			LODOP.SET_PRINT_STYLE("FontSize", sizeTwo);
			LODOP.ADD_PRINT_TEXT(25, 0, 580, sizeThree, chainName);
			LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
			LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
			LODOP.ADD_PRINT_LINE(50, 5, 50, 150, 1, 1);
			LODOP.SET_PRINT_STYLEA(0, "Bold", 1);

			height = 70;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "充值金额：" + money + " "
					+ deposit);
			LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
			LODOP.SET_PRINT_STYLE("FontSize", 10);
			height += 20;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "实际到账金额:" + calculatedAmt);
			LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
			LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
			height += 20;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "剩余充值金额："
					+ accumulateVipPrepaid);
			LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
			LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
			height += 20;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "备注：" + comment);
			LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
			LODOP.SET_PRINT_STYLE("FontSize", sizeThree);

			height += 40;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "此小票是充值凭证,请妥善保存");
			LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
			LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
			height += 20;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "服务热线：400—606—0849");
			LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
			LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
			height += 20;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "微信号：QXbaby-HK");
			LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
			LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
			height += 30;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "收银员:" + chainUser);
			LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
			height += 20;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, "欢迎下次光临：");
			LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
			height += 20;
			LODOP.ADD_PRINT_TEXT(height, 5, 580, 60, time);   
			LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
			LODOP.SET_PRINT_STYLE("FontSize", sizeThree);

			LODOP.SET_PRINT_PAGESIZE(1, 580, height * 3, "");

			//LODOP.PREVIEW();

			LODOP.PRINT();

		} catch (e) {
			alert("小票打印出现问题 ,请联系总部管理员");
		}

		document.vipPrepaidDepositForm.action = "actionChain/chainVIPJSPAction!preDepositVIPPrepaid";
		document.vipPrepaidDepositForm.submit();
	} else
		$.messager.alert('失败警告', response.message, 'error');
}


// 销售报表
function generateReportBackProcess3(data) {

	$.messager.progress('close');
	var report = data.report;

	if (report != undefined) {

		//打印连锁店名字
		var chainName = $("#chainName").val();
		//打印日期
		var startDate = $("#startDate").combo("getValue");
		var endDate = $("#endDate").combo("getValue");

		var date = new Date();
		var footer = "打印日期 : " + formatDate(date, "YYYY-MM-DD HH:mm:ss");

		LODOP.PRINT_INIT("连锁店单据过账——小票打印");
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		LODOP.ADD_PRINT_TEXT(5, 0, 580, 10, chainName + " " + "销售报表");
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		LODOP.ADD_PRINT_TEXT(25, 0, 580, sizeThree, startDate + "至" + endDate);
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		LODOP.ADD_PRINT_TEXT(50, 0, 580, sizeThree, footer);
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		LODOP.ADD_PRINT_LINE(70, 5, 70, 150, 1, 1);
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);

		height = 90;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "销售量："
				+ report.saleQuantitySum);
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "退货量:"
				+ report.returnQuantitySum);
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "净销售量:"
				+ report.netQuantitySum);
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP
				.ADD_PRINT_TEXT(height, 5, 580, 20, "赠品量:"
						+ report.freeQantitySum);
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "销售额:"
				+ (report.salesAmtSum).toFixed(1));
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "退货额:"
				+ (report.returnAmtSum).toFixed(1));
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "优惠总额:"
				+ (report.discountSum).toFixed(1));
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "代金卷:"
				+ (report.couponSum).toFixed(1));
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "积分换现金:"
				+ (report.vipScoreSum).toFixed(1));
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "刷卡:"
				+ (report.cardAmtSum).toFixed(1));
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "现金:"
				+ (report.cashNetSum).toFixed(1));
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "微信:"
				+ (report.wechatAmtSum).toFixed(1));
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "支付宝:"
				+ (report.alipaySum).toFixed(1));
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "销售折扣:"
				+ (report.salesDiscountAmtSum).toFixed(1));
		LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
		LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
		LODOP.SET_PRINT_PAGESIZE(1, 580, height * 3, "");

		//预览打印方法
		//LODOP.PREVIEW();

		LODOP.PRINT();

	}
	
}



/**
 * 打印备注单据
 */
function commentsOne(data, comment, chainName) {
	// 头部信息
	var head = data.chainStore.printHeader;
	// 单据号
	var id = data.id;
	// 单据号
	var totalQuantity = data.totalQuantity;
	// 高度
	var height = 60;
	var list = "";
	if (data.productList.length > 0) {
		for (i = 0; i < data.productList.length - 1; i++) {
			height += 15;
			list += "<tr><td>"
					+ data.productList[i].productBarcode.product.brand.brand_Name
					+ "</td><td>"
					+ data.productList[i].productBarcode.product.productCode
					+ data.productList[i].productBarcode.color.name
					+ "</td><td>" + data.productList[i].quantity
					+ "</td></tr>\n"

		}
	}

	commentsPrice(list, id, totalQuantity, comment, chainName, head, height);

}

// 备注单据小票打印
function commentsPrice(data, id, totalQuantity, comment, chainName, head,height) {
	
	var heightOne = height - 10;
	var myDate = new Date();
	var time = formatDate(myDate, "YYYY-MM-DD HH:mm:ss");

	LODOP.PRINT_INIT("备注单据——小票打印");
	LODOP.SET_PRINT_STYLE("FontSize", sizeOne);
	LODOP.ADD_PRINT_TEXT(5, 0, 580, 10, head);
	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
	LODOP.SET_PRINT_STYLE("FontSize", sizeTwo);
	LODOP.ADD_PRINT_TEXT(25, 0, 580, sizeThree, chainName);
	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
	LODOP.SET_PRINT_STYLE("FontSize", sizeThree);
	LODOP.ADD_PRINT_LINE(50, 5, 50, 150, 1, 1);
	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
	LODOP.ADD_PRINT_TABLE(60,1,440,height,"<style> table,td,th {border: 0px solid black; border-style: solid;border-collapse: collapse;font-size:11px;font-weight:bold;}  td{text-align:left;}</style>\n"
							+ "<table width='160px'><tr><td style='width:60px;'>品牌</td><td style='width:65px'>颜色货号</td><td style='width:25px'>数量</td></tr>\n"
							+ data + "</table>");
	height+=30;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "单据号:" + id);
	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
	LODOP.SET_PRINT_STYLE("FontSize", 8);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 580, 20, "合计数量:" + totalQuantity);
	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
	LODOP.SET_PRINT_STYLE("FontSize", 8);
	height += 20;
	LODOP.ADD_PRINT_TEXT(height, 5, 560, 20, "备注信息:" + comment.substring(0,18));
	if(comment.length>20){
		height += 20;
		LODOP.ADD_PRINT_TEXT(height, 5, 560, 20,  comment.substring(18,comment.length));
	}

	LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
	LODOP.SET_PRINT_STYLE("FontSize", 8);
	LODOP.SET_PRINT_PAGESIZE(1, 580, height * 3.1, "");
	//LODOP.PREVIEW();
	//打印设计
	LODOP.PRINT();

}


//获取当前时间并格式化为 "YYYY-MM-DD HH:mm:ss"
function getFormattedTime() {
  const now = new Date();

  // 补零函数（确保两位数格式）
  const pad = (num) => num.toString().padStart(2, '0');

  const year = now.getFullYear();     // 年份（四位数）
  const month = pad(now.getMonth() + 1); // 月份（0~11 → 补零后 01~12）
  const day = pad(now.getDate());     // 日期
  const hours = pad(now.getHours());  // 小时（24小时制）
  const minutes = pad(now.getMinutes()); // 分钟
  const seconds = pad(now.getSeconds()); // 秒

  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}


